<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$merchid=$this->checklogin();
if($_RQ['op']=='list'){
	$params=array('type <>'=>4,'merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid']);
	$params['onepluginname']='';
	$return['list']=pdo_getall('jy_weishop_goods',$params,array('id','title','image'));
	foreach($return['list'] as $k=>&$v){
		$v['total']=pdo_getsum('jy_weishop_order_goods',array('ispay'=>1,'goodsid'=>$v['id'],'uniacid'=>$_SESSION['uniacid']),'total');
		if(!$v['total']){
			unset($return['list'][$k]);
			continue;
		}
		$v['totalprice']=pdo_getsum('jy_weishop_order_goods',array('ispay'=>1,'goodsid'=>$v['id'],'uniacid'=>$_SESSION['uniacid']),'total_price');
	}
	paixu($return['list'],'total','desc');
	foreach($return['list'] as $k=>&$v){
		$v['rank']=$k+1;
	}
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','delall'=>false,'del_one'=>false,'edit'=>false,'list'=>array(
			array('name'=>'rank','title'=>'排行','type'=>'string'),
			array('name'=>'title','title'=>'商品名称','type'=>'string'),
			array('name'=>'image','title'=>'商品图片','type'=>'image'),			
			array('name'=>'total','title'=>'销售量','type'=>'string'),
			array('name'=>'totalprice','title'=>'销售额','type'=>'string'),
		)),
	
	);
	$return['htmls']=$htmls;
	exi($return);
}
